import request from '@/utils/request'

const prefixUrl = process.env.VUE_APP_SUPERSET_SERVER
/**
 * 获取项目统计配置
 * http://showdoc.wisetimes.cn:4999/web/#/255/2176
 * @returns
 */
export function getReportCfg (params = {}) {
  return request({
    url: prefixUrl + 'api/v1/dashboard',
    method: 'get',
    params
  })
}

/**
 * 获取指标组配置
 * http://showdoc.wisetimes.cn:4999/web/#/255/2177
 * @param {*} id
 * @returns
 */
export function getMetricsGroup (id, params = {}) {
  return request({
    url: prefixUrl + `api/v1/dashboard/${id}/charts`,
    method: 'get',
    params
  })
}

/**
 * 指标数据
 * http://192.168.88.247:4999/web/#/203/1589
 * @returns
 */
export function getReportData (params = {}) {
  return request({
    url: prefixUrl + 'api/v2/data_report/chart/data',
    method: 'get',
    params,
    timeout: 0
  })
}
/**
 * 导出csv
 * @returns
 */
export function exportReportData (params = {}) {
  return request({
    url: prefixUrl + 'api/v2/data_report/chart/export',
    method: 'get',
    params,
    responseType: 'blob',
    noInterceptors: true,
    timeout: 0
  })
}
